package dhu.cst.jnlwt.jiangnan181310209liwanting181310302.tally.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import java.util.ArrayList;
import java.util.List;

import dhu.cst.jnlwt.jiangnan181310209liwanting181310302.tally.R;
import dhu.cst.jnlwt.jiangnan181310209liwanting181310302.tally.entity.CategoryBean;

public class MyGridViewAdapter extends BaseAdapter {
    private List<CategoryBean> itemData;
    private Context mContext;

    public MyGridViewAdapter(List<CategoryBean> itemData,Context context){
        this.itemData = itemData;
        mContext = context;
    }

    @Override
    public int getCount() {
        return itemData.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View inflater = LayoutInflater.from(mContext).inflate(R.layout.item_record,null);
        ImageView imageView = (ImageView)inflater.findViewById(R.id.item_record_iv);
        imageView.setImageResource(itemData.get(position).getIcon());
        TextView textView = (TextView)inflater.findViewById(R.id.item_record_tv);
        textView.setText(itemData.get(position).getCategory());
        return inflater;
    }
}
